package com.huanletao.guava.it;

import com.google.common.base.Function;
import com.google.common.collect.Maps;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public  class Father {
    private Long id;
    private String name;

    public Father(Long id, String name) {
        this.id = id;
        this.name = name;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Father{" +
                "id=" + id +
                ", name='" + name + '\'' +
                '}';
    }

    public static void main(String[] args) {
        List<Father> fathers = new ArrayList<>();
        fathers.add(new Father(0001L,"zhangsan"));
        fathers.add(new Father(0002L,"zhangsan1"));
        fathers.add(new Father(0003L,"zhangsan2"));
        fathers.add(new Father(0004L,"zhangsan4"));
        fathers.add(new Father(0005L,"zhangsan6"));
        fathers.add(new Father(0007L,"zhangsan33"));

        Map<Long,Father> mappedMovies = Maps.uniqueIndex(fathers, from -> from.getId());

        System.out.println("mappedMovies = " + mappedMovies);
    }
}
